<?php
namespace app\manage\model;

//use function config;

class Banner extends BaseModel
{

    public function item()
    {
        return $this->hasMany('BannerItem', 'banner_id', 'id');
    }

    public static function getAll($page = 1, $size = 15)
    {
        return self::with('item,item.image')->order('create_time desc')
            ->paginate($size, true, ['page' => $page]);
    }

    public function getImgAttr($value, $data)
    {
        $temp = $value;
        if($value){
            $temp = config('setting.img_prefix') . $value;
        }
        return $temp;
    }
}